<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    
    <title>Test Support (numpy.testing) &mdash; NumPy v1.18 Manual</title>
    
    <link rel="stylesheet" type="text/css" href="../_static/css/spc-bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../_static/css/spc-extend.css">
    <link rel="stylesheet" href="../_static/scipy.css" type="text/css" >
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" >
    <link rel="stylesheet" href="../_static/graphviz.css" type="text/css" >
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.18.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script type="text/javascript" src="../_static/js/copybutton.js"></script>
    <link rel="author" title="About these documents" href="../about.html" >
    <link rel="index" title="Index" href="../genindex.html" >
    <link rel="search" title="Search" href="../search.html" >
    <link rel="top" title="NumPy v1.18 Manual" href="../index.html" >
    <link rel="up" title="Routines" href="routines.html" >
    <link rel="next" title="numpy.testing.assert_almost_equal" href="generated/numpy.testing.assert_almost_equal.html" >
    <link rel="prev" title="numpy.digitize" href="generated/numpy.digitize.html" > 
  </head>
  <body>
<div class="container">
  <div class="top-scipy-org-logo-header" style="background-color: #a2bae8;">
    <a href="../index.html">
      <img border=0 alt="NumPy" src="../_static/numpy_logo.png"></a>
    </div>
  </div>
</div>


    <div class="container">
      <div class="main">
        
	<div class="row-fluid">
	  <div class="span12">
	    <div class="spc-navbar">
              
    <ul class="nav nav-pills pull-left">
        <li class="active"><a href="https://numpy.org/">NumPy.org</a></li>
        <li class="active"><a href="https://numpy.org/doc">Docs</a></li>
        
        <li class="active"><a href="../index.html">NumPy v1.18 Manual</a></li>
        

          <li class="active"><a href="index.html" >NumPy Reference</a></li>
          <li class="active"><a href="routines.html" accesskey="U">Routines</a></li> 
    </ul>
              
              
    <ul class="nav nav-pills pull-right">
      <li class="active">
        <a href="../genindex.html" title="General Index"
           accesskey="I">index</a>
      </li>
      <li class="active">
        <a href="generated/numpy.testing.assert_almost_equal.html" title="numpy.testing.assert_almost_equal"
           accesskey="N">next</a>
      </li>
      <li class="active">
        <a href="generated/numpy.digitize.html" title="numpy.digitize"
           accesskey="P">previous</a>
      </li>
    </ul>
              
	    </div>
	  </div>
	</div>
        

	<div class="row-fluid">
      <div class="spc-rightsidebar span3">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Test Support (<code class="xref py py-mod docutils literal notranslate"><span class="pre">numpy.testing</span></code>)</a><ul>
<li><a class="reference internal" href="#asserts">Asserts</a></li>
<li><a class="reference internal" href="#decorators">Decorators</a></li>
<li><a class="reference internal" href="#test-running">Test Running</a></li>
<li><a class="reference internal" href="#guidelines">Guidelines</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="generated/numpy.digitize.html"
                        title="previous chapter">numpy.digitize</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="generated/numpy.testing.assert_almost_equal.html"
                        title="next chapter">numpy.testing.assert_almost_equal</a></p>
<div id="searchbox" style="display: none" role="search">
  <h4>Quick search</h4>
    <div>
    <form class="search" action="../search.html" method="get">
      <input type="text" style="width: inherit;" name="q" />
      <input type="submit" value="search" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
          <div class="span9">
            
        <div class="bodywrapper">
          <div class="body" id="spc-section-body">
            
  <span class="target" id="module-numpy.testing"></span><div class="section" id="test-support-numpy-testing">
<h1>Test Support (<a class="reference internal" href="#module-numpy.testing" title="numpy.testing"><code class="xref py py-mod docutils literal notranslate"><span class="pre">numpy.testing</span></code></a>)<a class="headerlink" href="#test-support-numpy-testing" title="Permalink to this headline">¶</a></h1>
<p>Common test support for all numpy test scripts.</p>
<p>This single module should provide all the common functionality for numpy
tests in a single location, so that <a class="reference internal" href="../dev/development_environment.html#development-environment"><span class="std std-ref">test scripts</span></a> can just import it and work right away. For
background, see the <a class="reference internal" href="testing.html#testing-guidelines"><span class="std std-ref">Testing Guidelines</span></a></p>
<div class="section" id="asserts">
<h2>Asserts<a class="headerlink" href="#asserts" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.assert_almost_equal.html#numpy.testing.assert_almost_equal" title="numpy.testing.assert_almost_equal"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_almost_equal</span></code></a>(actual, desired[, …])</p></td>
<td><p>Raises an AssertionError if two items are not equal up to desired precision.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.testing.assert_approx_equal.html#numpy.testing.assert_approx_equal" title="numpy.testing.assert_approx_equal"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_approx_equal</span></code></a>(actual, desired[, …])</p></td>
<td><p>Raises an AssertionError if two items are not equal up to significant digits.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.assert_array_almost_equal.html#numpy.testing.assert_array_almost_equal" title="numpy.testing.assert_array_almost_equal"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_array_almost_equal</span></code></a>(x, y[, decimal, …])</p></td>
<td><p>Raises an AssertionError if two objects are not equal up to desired precision.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.testing.assert_allclose.html#numpy.testing.assert_allclose" title="numpy.testing.assert_allclose"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_allclose</span></code></a>(actual, desired[, rtol, …])</p></td>
<td><p>Raises an AssertionError if two objects are not equal up to desired tolerance.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.assert_array_almost_equal_nulp.html#numpy.testing.assert_array_almost_equal_nulp" title="numpy.testing.assert_array_almost_equal_nulp"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_array_almost_equal_nulp</span></code></a>(x, y[, nulp])</p></td>
<td><p>Compare two arrays relatively to their spacing.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.testing.assert_array_max_ulp.html#numpy.testing.assert_array_max_ulp" title="numpy.testing.assert_array_max_ulp"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_array_max_ulp</span></code></a>(a, b[, maxulp, dtype])</p></td>
<td><p>Check that all items of arrays differ in at most N Units in the Last Place.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.assert_array_equal.html#numpy.testing.assert_array_equal" title="numpy.testing.assert_array_equal"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_array_equal</span></code></a>(x, y[, err_msg, verbose])</p></td>
<td><p>Raises an AssertionError if two array_like objects are not equal.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.testing.assert_array_less.html#numpy.testing.assert_array_less" title="numpy.testing.assert_array_less"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_array_less</span></code></a>(x, y[, err_msg, verbose])</p></td>
<td><p>Raises an AssertionError if two array_like objects are not ordered by less than.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.assert_equal.html#numpy.testing.assert_equal" title="numpy.testing.assert_equal"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_equal</span></code></a>(actual, desired[, err_msg, verbose])</p></td>
<td><p>Raises an AssertionError if two objects are not equal.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.testing.assert_raises.html#numpy.testing.assert_raises" title="numpy.testing.assert_raises"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_raises</span></code></a>(exception_class, callable, …)</p></td>
<td><p>Fail unless an exception of class exception_class is thrown by callable when invoked with arguments args and keyword arguments kwargs.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.assert_raises_regex.html#numpy.testing.assert_raises_regex" title="numpy.testing.assert_raises_regex"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_raises_regex</span></code></a>(exception_class, …)</p></td>
<td><p>Fail unless an exception of class exception_class and with message that matches expected_regexp is thrown by callable when invoked with arguments args and keyword arguments kwargs.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.testing.assert_warns.html#numpy.testing.assert_warns" title="numpy.testing.assert_warns"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_warns</span></code></a>(warning_class, \*args, \*\*kwargs)</p></td>
<td><p>Fail unless the given callable throws the specified warning.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.assert_string_equal.html#numpy.testing.assert_string_equal" title="numpy.testing.assert_string_equal"><code class="xref py py-obj docutils literal notranslate"><span class="pre">assert_string_equal</span></code></a>(actual, desired)</p></td>
<td><p>Test if two strings are equal.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="decorators">
<h2>Decorators<a class="headerlink" href="#decorators" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.dec.deprecated.html#numpy.testing.dec.deprecated" title="numpy.testing.dec.deprecated"><code class="xref py py-obj docutils literal notranslate"><span class="pre">dec.deprecated</span></code></a>([conditional])</p></td>
<td><p>Filter deprecation warnings while running the test suite.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.testing.dec.knownfailureif.html#numpy.testing.dec.knownfailureif" title="numpy.testing.dec.knownfailureif"><code class="xref py py-obj docutils literal notranslate"><span class="pre">dec.knownfailureif</span></code></a>(fail_condition[, msg])</p></td>
<td><p>Make function raise KnownFailureException exception if given condition is true.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.dec.setastest.html#numpy.testing.dec.setastest" title="numpy.testing.dec.setastest"><code class="xref py py-obj docutils literal notranslate"><span class="pre">dec.setastest</span></code></a>([tf])</p></td>
<td><p>Signals to nose that this function is or is not a test.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.testing.dec.skipif.html#numpy.testing.dec.skipif" title="numpy.testing.dec.skipif"><code class="xref py py-obj docutils literal notranslate"><span class="pre">dec.skipif</span></code></a>(skip_condition[, msg])</p></td>
<td><p>Make function raise SkipTest exception if a given condition is true.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.dec.slow.html#numpy.testing.dec.slow" title="numpy.testing.dec.slow"><code class="xref py py-obj docutils literal notranslate"><span class="pre">dec.slow</span></code></a>(t)</p></td>
<td><p>Label a test as ‘slow’.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.testing.decorate_methods.html#numpy.testing.decorate_methods" title="numpy.testing.decorate_methods"><code class="xref py py-obj docutils literal notranslate"><span class="pre">decorate_methods</span></code></a>(cls, decorator[, testmatch])</p></td>
<td><p>Apply a decorator to all methods in a class matching a regular expression.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="test-running">
<h2>Test Running<a class="headerlink" href="#test-running" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.Tester.html#numpy.testing.Tester" title="numpy.testing.Tester"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Tester</span></code></a></p></td>
<td><p>alias of <code class="xref py py-class docutils literal notranslate"><span class="pre">numpy.testing._private.nosetester.NoseTester</span></code></p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.testing.run_module_suite.html#numpy.testing.run_module_suite" title="numpy.testing.run_module_suite"><code class="xref py py-obj docutils literal notranslate"><span class="pre">run_module_suite</span></code></a>([file_to_run, argv])</p></td>
<td><p>Run a test module.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.testing.rundocs.html#numpy.testing.rundocs" title="numpy.testing.rundocs"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rundocs</span></code></a>([filename, raise_on_error])</p></td>
<td><p>Run doctests found in the given file.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.testing.suppress_warnings.html#numpy.testing.suppress_warnings" title="numpy.testing.suppress_warnings"><code class="xref py py-obj docutils literal notranslate"><span class="pre">suppress_warnings</span></code></a>([forwarding_rule])</p></td>
<td><p>Context manager and decorator doing much the same as <code class="docutils literal notranslate"><span class="pre">warnings.catch_warnings</span></code>.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="guidelines">
<h2>Guidelines<a class="headerlink" href="#guidelines" title="Permalink to this headline">¶</a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="testing.html">Testing Guidelines</a><ul>
<li class="toctree-l2"><a class="reference internal" href="testing.html#introduction">Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="testing.html#writing-your-own-tests">Writing your own tests</a><ul>
<li class="toctree-l3"><a class="reference internal" href="testing.html#labeling-tests">Labeling tests</a></li>
<li class="toctree-l3"><a class="reference internal" href="testing.html#easier-setup-and-teardown-functions-methods">Easier setup and teardown functions / methods</a></li>
<li class="toctree-l3"><a class="reference internal" href="testing.html#parametric-tests">Parametric tests</a></li>
<li class="toctree-l3"><a class="reference internal" href="testing.html#doctests">Doctests</a></li>
<li class="toctree-l3"><a class="reference internal" href="testing.html#tests"><code class="docutils literal notranslate"><span class="pre">tests/</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="testing.html#init-py-and-setup-py"><code class="docutils literal notranslate"><span class="pre">__init__.py</span></code> and <code class="docutils literal notranslate"><span class="pre">setup.py</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="testing.html#tips-tricks">Tips &amp; Tricks</a><ul>
<li class="toctree-l3"><a class="reference internal" href="testing.html#creating-many-similar-tests">Creating many similar tests</a></li>
<li class="toctree-l3"><a class="reference internal" href="testing.html#known-failures-skipping-tests">Known failures &amp; skipping tests</a></li>
<li class="toctree-l3"><a class="reference internal" href="testing.html#tests-on-random-data">Tests on random data</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>


          </div>
        </div>
          </div>
        </div>
      </div>
    </div>

    <div class="container container-navbar-bottom">
      <div class="spc-navbar">
        
      </div>
    </div>
    <div class="container">
    <div class="footer">
    <div class="row-fluid">
    <ul class="inline pull-left">
      <li>
        &copy; Copyright 2008-2019, The SciPy community.
      </li>
      <li>
      Last updated on Feb 20, 2020.
      </li>
      <li>
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.4.2.
      </li>
    </ul>
    </div>
    </div>
    </div>
  </body>
</html>